<template>
  <div>
    <editCloudBuildInput v-if="detailType===2" :isAudit="isAudit" :isConsultation="isConsultation" />
    <editOrdinaryContract v-if="detailType===0" :isAudit="isAudit" :isConsultation="isConsultation"/>
    <editSupplementaryAgreement v-if="detailType===1" :isAudit="isAudit" :isConsultation="isConsultation"/>
  </div>
</template>

<script>
import editCloudBuildInput from './editCloudBuildInput'
import editOrdinaryContract from './editOrdinaryContract'
import editSupplementaryAgreement from './editSupplementaryAgreement'
import subcontract from '@/api/legal/branchContract/subcontract'

export default {
  name: 'a' + Date.now(),
  components: {
    editCloudBuildInput,
    editOrdinaryContract,
    editSupplementaryAgreement
  },
  props: {
    isAudit: {
      type: Boolean,
      default: false
    },
    // 是否作为意见征询
    isConsultation: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      detailType: -1//0:主合同，1：补充协议，2：补录
    }
  },
  created() {
    this.getData()
  },
  methods: {
    async getData() {
      let res = await subcontract.findById({}, { id: this.$route.query.id })
      if (res.code === this.SUCCESS_CODE) {
        if (res.data.fromStatus == '0') {
          this.detailType = 2
        } else {
          let processTrend = Number(res.data.processTrend)
          if (processTrend === 3 || processTrend == '3') {
            this.detailType = 1
          } else {
            this.detailType = 0
          }
        }
      }
    }
  }
}
</script>

<style scoped>
.ant-card {
  margin: 20px;
}
</style>
